package org.dromara.system.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum WithdrawalStatusEnum {

    PENDING_APPROVAL(1, "提现发起"),
    AGREE_WITHDRAWAL(2, "提现同意"),
    REJECT_WITHDRAWAL(3, "提现驳回"),
    SUCCESSFUL_WITHDRAWAL(4, "提现成功"),
    FAILED_WITHDRAWAL(5, "提现失败"),
    TO_BE_CLAIMED_WITHDRAWAL(6, "提现待领取"),
    AWAITING_CONFIRMATION(7, "待确认到账"),

    ;
    @JsonValue
    @EnumValue
    private final Integer code;
    private final String name;

    public static WithdrawalStatusEnum findOne(Integer code) {
        return Arrays.stream(WithdrawalStatusEnum.values())
            .filter(type -> type.getCode().equals(code)).findAny().orElse(null);
    }
}
